import Vue from 'vue'
import VueRouter from 'vue-router'
import Frame from "../src/components/frame.vue";
import {
	RouterTabRoutes
} from 'vue-router-tab';

const importPage = view => () =>
	import(`../page/${view}.vue`)

Vue.use(VueRouter);

const routes = [
	{
		path: '/',
		component: Frame,
		meta: {
			title: '主页' // 页签标题
		},
		children: [
			// 引入 RouterTab 内置路由以支持 iframe 页签
			...RouterTabRoutes,
			{
				path: '/', // 默认页和父级路由一致
				name: 'index',
				component: importPage('index'),
				meta: {
					title: '主页' // 页签标题
				}
			},
			// {
			// 	path: '/index-shop', // 默认页和父级路由一致
			// 	name: 'index-shop',
			// 	component: importPage('index-shop'),
			// 	meta: {
			// 		title: '主页' // 页签标题
			// 	}
			// },
			{
				path: '/user',
				name: 'user',
				component: importPage('user/list'),
				meta: {
					title: '用户管理' // 页签标题
				}
			},
			{
				path: '/user/new',
				name: 'user_new',
				component: importPage('user/new'),
				meta: {
					title: '用户新增' // 页签标题
				}
			},
			{
				path: '/user/detail',
				name: 'user_detail',
				component: importPage('user/detail'),
				meta: {
					title: '用户详情' // 页签标题
				}
			},
			{
				path: '/role',
				name: 'role',
				component: importPage('role/list'),
				meta: {
					title: '角色列表' // 页签标题
				}
			},
			{
				path: '/role/new',
				name: 'role_new',
				component: importPage('role/new'),
				meta: {
					title: '新增角色' // 页签标题
				}
			},
			{
				path: '/role/detail',
				name: 'role_detail',
				component: importPage('role/detail'),
				meta: {
					title: '角色详细' // 页签标题
				}
			},
			{
				path: '/permission',
				name: 'permission',
				component: importPage('permission/list'),
				meta: {
					title: '权限列表' // 页签标题
				}
			},
			{
				path: '/permission/new',
				name: 'permission_new',
				component: importPage('permission/new'),
				meta: {
					title: '新增权限' // 页签标题
				}
			},
			{
				path: '/permission/detail',
				name: 'permission_detail',
				component: importPage('permission/detail'),
				meta: {
					title: '权限详细' // 页签标题
				}
			},
									
			{
				path: '/order',
				name: 'order',
				component: importPage('order/list'),
				meta: {
					title: '订单列表' // 页签标题
				}
			},
			{
				path: '/order/detail',
				name: 'order_detail',
				component: importPage('order/detail'),
				meta: {
					title: '订单详情' // 页签标题
				}
			},
			
			{
				path: '/client',
				name: 'client',
				component: importPage('client/list'),
				meta: {
					title: '客户列表' // 页签标题
				}
			},
			{
				path: '/client/detail',
				name: 'client_detail',
				component: importPage('client/detail'),
				meta: {
					title: '客户详情' // 页签标题
				}
			},
			
			{
				path: '/vip',
				name: 'vip',
				component: importPage('vip/list'),
				meta: {
					title: '会员列表' // 页签标题
				}
			},
			{
				path: '/vip/detail',
				name: 'vip_detail',
				component: importPage('vip/detail'),
				meta: {
					title: '会员详情' // 页签标题
				}
			},
			
			{
				path: '/cardType',
				name: 'cardType',
				component: importPage('cardType/list'),
				meta: {
					title: '会员卡类型列表' // 页签标题
				}
			},
			{
				path: '/cardType/detail',
				name: 'cardType_detail',
				component: importPage('cardType/detail'),
				meta: {
					title: '会员卡类型详情' // 页签标题
				}
			},
			{
				path: '/cardType/new',
				name: 'cardType_new',
				component: importPage('cardType/new'),
				meta: {
					title: '会员卡类型新增' // 页签标题
				}
			},
			
			{
				path: '/voucherType',
				name: 'voucherType',
				component: importPage('voucherType/list'),
				meta: {
					title: '会员券类型列表' // 页签标题
				}
			},
			{
				path: '/voucherType/detail',
				name: 'voucherType_detail',
				component: importPage('voucherType/detail'),
				meta: {
					title: '会员券类型详情' // 页签标题
				}
			},
			{
				path: '/voucherType/new',
				name: 'voucherType_new',
				component: importPage('voucherType/new'),
				meta: {
					title: '会员券类型新增' // 页签标题
				}
			},
			
			{
				path: '/voucher',
				name: 'voucher',
				component: importPage('voucher/list'),
				meta: {
					title: '会员券列表' // 页签标题
				}
			},
			{
				path: '/voucher/detail',
				name: 'voucher_detail',
				component: importPage('voucher/detail'),
				meta: {
					title: '会员券详情' // 页签标题
				}
			},
			{
				path: '/voucher/new',
				name: 'voucher_new',
				component: importPage('voucher/new'),
				meta: {
					title: '会员券新增' // 页签标题
				}
			},
			
			{
				path: '/store',
				name: 'store',
				component: importPage('store/list'),
				meta: {
					title: '门店列表' // 页签标题
				}
			},
			{
				path: '/store/detail/:storeId',
				name: 'store_detail',
				component: importPage('store/detail'),
				meta: {
					key: 'fullPath',
					title: '门店详情' // 页签标题
				}
			},
			{
				path: '/store/new',
				name: 'store_new',
				component: importPage('store/new'),
				meta: {
					title: '门店新增' // 页签标题
				}
			},
			
			{
				path: '/wxServer/detail',
				name: 'wxServer_detail',
				component: importPage('wxServer/detail'),
				meta: {
					title: '公众号详情' // 页签标题
				}
			},
			{
				path: '/wxServer/new',
				name: 'wxServer_new',
				component: importPage('wxServer/new'),
				meta: {
					title: '公众号新增' // 页签标题
				}
			},
			
			{
				path: '/access',
				name: 'access',
				component: importPage('access/list'),
				meta: {
					title: '门禁列表' // 页签标题
				}
			},
			{
				path: '/access/detail',
				name: 'access_detail',
				component: importPage('access/detail'),
				meta: {
					title: '门禁详情' // 页签标题
				}
			},
			{
				path: '/access/new',
				name: 'access_new',
				component: importPage('access/new'),
				meta: {
					title: '门禁新增' // 页签标题
				}
			},
			
			{
				path: '/accessRecord',
				name: 'accessRecord',
				component: importPage('accessRecord/list'),
				meta: {
					title: '门禁记录列表' // 页签标题
				}
			},
			
			{
				path: '/depositRecord',
				name: 'depositRecord',
				component: importPage('depositRecord/list'),
				meta: {
					title: '押金记录列表' // 页签标题
				}
			},
			{
				path: '/depositRecord/detail',
				name: 'depositRecord_detail',
				component: importPage('depositRecord/detail'),
				meta: {
					title: '押金记录详情' // 页签标题
				}
			},
			
			{
				path: '/depositRecordV2',
				name: 'depositRecordV2',
				component: importPage('depositRecord/listv2'),
				meta: {
					title: '押金记录列表' // 页签标题
				}
			},
			{
				path: '/depositRecord/detailV2',
				name: 'depositRecord_detailV2',
				component: importPage('depositRecord/detailv2'),
				meta: {
					title: '押金记录详情' // 页签标题
				}
			},
			
			{
				path: '/depositBackRequest',
				name: 'depositBackRequest',
				component: importPage('depositBackRequest/list'),
				meta: {
					title: '退押申请列表' // 页签标题
				}
			},
			{
				path: '/depositBackRequest/detail',
				name: 'depositBackRequest_detail',
				component: importPage('depositBackRequest/detail'),
				meta: {
					title: '退押申请详情' // 页签标题
				}
			},
			
			{
				path: '/cutDepositRecord',
				name: 'cutDepositRecord',
				component: importPage('cutDepositRecord/list'),
				meta: {
					title: '扣押记录列表' // 页签标题
				}
			},
			{
				path: '/cutDepositRecord/detail',
				name: 'cutDepositRecord_detail',
				component: importPage('cutDepositRecord/detail'),
				meta: {
					title: '扣押记录详情' // 页签标题
				}
			},
			
			{
				path: '/cutDepositRecord/new',
				name: 'cutDepositRecord_new',
				component: importPage('cutDepositRecord/new'),
				meta: {
					title: '新增扣押' // 页签标题
				}
			},
			{
				path: '/price/detail',
				name: 'price_detail',
				component: importPage('price/detail'),
				meta: {
					title: '价格信息' // 页签标题
				}
			},{
				path: '/shop',
				name: 'shop',
				component: importPage('shop/index-shop'),
				meta: {
					title: '门店' // 页签标题
				}
			},
			{
				path: '/shop/depositRecord',
				name: 'shop_depositRecord',
				component: importPage('shop/depositRecord'),
				meta: {
					title: '押金记录' // 页签标题
				}
			},
			{
				path: '/shop/order',
				name: 'shop_order',
				component: importPage('shop/order'),
				meta: {
					title: '临时订单' // 页签标题
				}
			},
			{
				path: '/shop/vip',
				name: 'shop_vip',
				component: importPage('shop/vip'),
				meta: {
					title: '用户管理' // 页签标题
				}
			},
			{
				path: '/shop/people',
				name: 'shop_people',
				component: importPage('shop/people'),
				meta: {
					title: '人数' // 页签标题
				}
			},
			
			{
				path: '/page/:id',
				name: 'Page',
				component: importPage('Page'),
				meta: {
					key: 'path',
					title(route) {
						return `Page ${route.params.id}`
					}
				}
			},
			{
				path: '/deposit/detail',
				name: 'deposit_detail',
				component: importPage('deposit/detail'),
				meta: {
					title: '押金信息' // 页签标题
				}
			},
		]
	},
	{
		path: '/dashboard',
		name: 'dashboard',
		component: importPage('dashboard/dashboard'),
	}
];

const router = new VueRouter({
	routes
});
const originalPush = VueRouter.prototype.push;
// VueRouter.prototype.push = function push(location) {
// 	return originalPush.call(this, location).catch(err => err)
// }

VueRouter.prototype.push = VueRouter.prototype.replace;



export default router;
